package com.yingran.beiqi

import android.content.Context
import android.view.Gravity
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.yingran.beiqi.activity.MainActivity
import com.yingran.common.util.dp2px

class MenuView(context: Context, menu: MainActivity.Menus) : LinearLayout(context) {
    var menu: MainActivity.Menus? = null

    init {
        orientation = LinearLayout.VERTICAL
        this@MenuView.menu = menu
        gravity = Gravity.CENTER
        setOnClickListener { }
        val imageView = ImageView(context)
        imageView.setImageResource(menu.resId)
        val layoutParams = LinearLayout.LayoutParams(dp2px(60), dp2px(60))
        addView(imageView, layoutParams)
        val textView = TextView(context)
        textView.text = menu.label
        val paramsTv = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
        addView(textView, paramsTv)
    }
}
